package bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

public class DataroomDTO {
	Connection conn;
	DataroomVo vo;
	
	public DataroomDTO()
	{
		conn = new MyOracle1().getConn();
	}
	
	public ArrayList<DataroomVo> preSelect()
	{
		ArrayList<DataroomVo> al = new ArrayList<DataroomVo>();
		try
		{
			String sql = "select rownum, a.* from(select * from dataroom order by num desc)a where rownum between 1 and 3";
			PreparedStatement pst = conn.prepareStatement(sql);
			ResultSet rs = pst.executeQuery();
			while(rs.next())
			{
				DataroomVo v = new DataroomVo();
				v.setNum(rs.getInt("num"));
				v.setMid(rs.getString("mid"));
				v.setTitle(rs.getString("title"));
				v.setCat(rs.getInt("cat"));
				v.setWdate(rs.getString("wdate"));
//				if(rs.getString("data").equals(null)==false)
				if(rs.getString("data")!=null)
				{
					v.setData(rs.getString("data"));
				}
//				System.out.println(v.getNum()+"/"+v.getMid()+"/"+v.getTitle()+"/"+v.getCat()+"/"+v.getWdate()+"/"+v.getData());
				al.add(v);
			}
			rs.close();
			pst.close();
			conn.close();
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		
		return al;
	}
	
	
	public DataroomVo getVo() {
		return vo;
	}

	public void setVo(DataroomVo vo) {
		this.vo = vo;
	}
}
